<template>
  <div class="index">
    <van-nav-bar title="成绩页面" left-text="返回" right-text="排行榜" left-arrow @click-left="onClickLeft" @click-right="onClickRight" />

    <!-- 分数  {{ showSorceDate.scroe }}分-->
    <div class="wave">
      <!-- 水球波纹效果 -->
      <div class="wave4">{{ showSorceDate.scroe }}分</div>
      <div class="wave1"></div>
      <div class="wave2"></div>
      <div class="wave3"></div>
    </div>
    <!-- 各科百分比 -->
    <div class="connect">
      <!-- 科目 -->
      <div class="con" v-cloak>科目: {{ showSorceDate.subject_name }}</div>
      <!-- 单 -->
      <div class="con" v-cloak>单选题: {{ single_scroefun }}</div>
      <!-- 多 -->
      <div class="con">多选题: {{ selection_scroefun }}</div>
      <!-- 判断-->
      <div class="con">判断题: {{ judge_scroefun }}</div>
      <!-- 操作 -->
      <div class="con">操作题: {{ operation_scroefun }}</div>
      <div class="con" @click="showError"><van-button round type="info">查看错题</van-button></div>
    </div>
  </div>
</template>

<script>
import axios from 'axios'
import { NavBar, Toast } from 'vant'
import { Button } from 'vant'

export default {
  name: 'sroucxq',
  data() {
    return {
      showSorceDate: []
    }
  },
  methods: {
    // Toast('返回');
    onClickLeft() {
      this.$router.push('/sroucIndex')
    },
    // 查看排行榜
    onClickRight() {
      this.$router.push('/ranking')
    },
    // 查看错题
    showError() {
      this.$router.push('/showError')
    }
  },
  // 计算属性
  computed: {
    // 单3 多4 判断2 操作20 计算答对百分比
    // 单
    single_scroefun() {
      return (this.showSorceDate.single_scroe / (3 * 10)) * 100 + '%'
    },
    // 多
    selection_scroefun() {
      return (this.showSorceDate.selection_scroe / (4 * 10)) * 100 + '%'
    },
    // 判断
    judge_scroefun() {
      return (this.showSorceDate.judge_scroe / (2 * 5)) * 100 + '%'
    },
    // 操作
    operation_scroefun() {
      return (this.showSorceDate.operation_scroe / (20 * 1)) * 100 + '%'
    }
  },

  created() {
    axios({
      method: 'post',
      url: this.baseURL + '/api/api/showSorce',
      data: {
        id: localStorage.getItem('showSorce_id')
      }
    }).then((res) => {
      // console.log(res)
      if (res.data.code == 0) {
        this.$router.push('/sroucIndex')
        Toast('教师未审卷')
      }
      this.showSorceDate = res.data
    })
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
[v-cloak] {
  display: none;
}
.index {
  background-image: url('../assets/tu9.jpg');
  width: 100%;
  height: 100%;
  position: fixed;
  background-size: 100% 100%;
}

.connect {
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.con {
  margin: 20px 10px;
  font-size: 16px;
}
.wave {
  position: relative;
  border: 1px solid silver;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  line-height: 50px;
  margin: 20px auto;
  font-size: 14px;
  text-align: center;
  overflow: hidden;
  animation: water-wave linear infinite;
}
.wave1 {
  position: absolute;
  top: 40%;
  left: -25%;
  background: #33cfff;
  opacity: 0.7;
  width: 200%;
  height: 200%;
  border-radius: 40%;
  animation: inherit;
  animation-duration: 4s;
}
.wave2 {
  position: absolute;
  top: 40%;
  left: -35%;
  background: #0eaffe;
  opacity: 0.7;
  width: 200%;
  height: 200%;
  border-radius: 35%;
  animation: inherit;
  animation-duration: 6s;
}
.wave3 {
  position: absolute;
  top: 40%;
  left: -45%;
  background: #0f7ea4;
  opacity: 0.3;
  width: 200%;
  height: 200%;
  border-radius: 40%;
  animation: inherit;
  animation-duration: 8s;
}
@keyframes water-wave {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
.wave4 {
  margin: 40px;
  font-size: 20px;
}
</style>
